package com.hsav.kcxb.adapter.common;

import android.util.SparseArray;
import android.view.View;

/**
 * Created by zhao on 17-4-29.
 */

public class CommonViewHolder {

    public static <T extends View> T get(View view, int id) {
        SparseArray<View> viewSparseArray = (SparseArray<View>) view.getTag();
        if (viewSparseArray == null) {
            viewSparseArray = new SparseArray<>();
            view.setTag(viewSparseArray);
        }
        View childView = viewSparseArray.get(id);
        if(childView==null){
            childView = view.findViewById(id);
            viewSparseArray.put(id,childView);
        }

        return (T)childView;
    }
}
